package com.aruba.navigation;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    private NavController navController;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //获取NavController对象
        navController = Navigation.findNavController(this, R.id.fragmentContainerView);
        //将ActionBar与NavController绑定
        NavigationUI.setupActionBarWithNavController(this, navController);
    }

    //actionbar的返回按钮点击
    @Override
    public boolean onSupportNavigateUp() {
        return navController.navigateUp();
    }
}